package game.entities;

import game.gfx.Screen;
import game.level.Level;
import game.level.tiles.Tile;

public abstract class Entity {

	public int x,y;
	protected Level level;
	public boolean hasHitbox;
	public boolean isEnemy;
	
	public Entity(Level level){
		init(level);
	}
	
	public final void init(Level level){
		this.level = level;
	}
	
	public abstract void tick();
	
	public abstract void render(Screen screen);
	
	public void updateLevel(Level level) {
		this.level = level;
	}
	protected boolean isSolidTile(int xa, int ya, int x, int y) {
		if (level == null)
			return false;
		Tile lastTile = level.getTile((this.x + x) >> 3, (this.y + y) >> 3);
		Tile newTile = level.getTile((this.x + x + xa) >> 3,(this.y + y + ya) >> 3);
		if (!lastTile.equals(newTile) && newTile.isSolid()) {
			return true;
		}
		return false;
	}
}

